//
//  CacheTools.m
//  yuemeclient
//
//  Created by wenhongquan on 16/2/21.
//  Copyright © 2016年 wenhongquan. All rights reserved.
//




#import "CacheTools.h"

//NSString *const LocationCityName = @"locationCityName";
//NSString *const kMHAccountProfile = @"kMHAccountProfile";
//NSString *const kShareCreate = @"kShareCreate";
//NSString *const isShowAlert = @"isShowAlert";


//NSString *const TT_LOCATIONCITY = @"TT_LOCATIONCITY";

#define APPLICATIONCACHHE @"yuemeclientcache"

@interface CacheTools()

@property(nonatomic,copy)YYCache *cache;

@end


@implementation CacheTools

OBJC_IMPL_SINGLETON(CacheTools);

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
        NSString *path = [docDir stringByAppendingPathComponent:APPLICATIONCACHHE];
        _cache = [[YYCache alloc] initWithPath:path];
    }
    return self;
}

-(void)setObjectForKey:(id)obj key:(NSString *)key{

    if (obj && key && [key isKindOfClass:[NSString class]]) {
        [_cache setObject:obj forKey:key];
    }
}

-(id)getObjForKey:(NSString *)key{

    return [_cache objectForKey:key];
}

-(void)removekey:(NSString *)key{
    [_cache removeObjectForKey:key];
}

-(void)clearCache{
    [_cache removeAllObjectsWithBlock:^{
        
    }];
}

- (YYMemoryCache *)memoryCache {
    return _cache.memoryCache;
}

@end
